<?php
function getToken($login, $pwd) {

   $ACCESSOR_URL = 'http://axe.mappy.com/1v1/'; // Prod

   $timestamp = round(time(true));

   $hash = md5($login."@".$pwd."@".$timestamp);
   $preToken =  $login."@".$timestamp."@".$hash;

   $remoteAddr = urlencode($_SERVER["REMOTE_ADDR"]);

   $urlGetToken = $ACCESSOR_URL . 'token/generate.aspx?auth=' . urlencode($preToken) . '&ip=' . $remoteAddr;

   $fh = @fopen($urlGetToken, 'rb') ;
   if ($fh == false) {

      return false;
   }
   $token = '';
   while (!feof($fh)) {
     $token .= fread($fh, 8192);
   }
   fclose($fh);

   return $token;
}

?>
